package com.dreampharos.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; 

/**
 * Copyright 2005 ICOS.CO.KR, Inc. All Rights Reserved.
 * Description:
 *
 * @author �����
 * @version 1.0
 * @since 2005. 7. 12.
 * Revision:
 */
public final class I18nUtil {

    public static final String DEFAULT_CHARSET = "MS949";
    public static final String KOR_CHARSET = "MS949"; //EUC-KR
    public static final String ENG_CHARSET = "ISO-8859-1";
    
    private I18nUtil() {}

    /**
    * ������ �ѱ۷� Conversion���ִ� ���α׷�.
    * @param english �ѱ۷� �ٲپ��� ���� String
    * @return �ѱ۷� �ٲپ��� String
    */
    public static String E2K(String english) {
        String korean = null;
    
        if (english == null ) {
            return null;
        }
        
        try { 
            korean = new String(english.getBytes(ENG_CHARSET), KOR_CHARSET);
        } catch (UnsupportedEncodingException e) {
            korean = new String(english);
        }

        return korean;
    }

    /**
    * �ѱ��� �������� Conversion���ִ� ���α׷�.
    * @param korean �������� �ٲپ��� �ѱ� String
    * @return ������ �ٲپ��� String
    */
    public static String K2E(String korean) {
        String english = null;
        
        if (korean == null ) {
            return null;
        }
        
        try { 
            english = new String(korean.getBytes(KOR_CHARSET), ENG_CHARSET);
        } catch (UnsupportedEncodingException e) {
            english = new String(korean);
        }

        return english;
    }

    /**
     * Method encode.
     * @param s
     * @return String
     */
    public static String encode(String s) {
        try {
            return URLEncoder.encode(s, DEFAULT_CHARSET);
        } catch (UnsupportedEncodingException e) {
            return s;
        }
    }

}











